<?php

class My_Auth_Adapter_Facebook  implements Zend_Auth_Adapter_Interface
{
    /**
     *
     * @var Facebook
     */

    private $_facebook;


    /**
     *
     * @param Facebook $facebook 
     */

    public function __construct(Facebook $facebook)
    {
        $this->_facebook = $facebook;
    }

    public function authenticate()
    {
        $db = Zend_Db_Table::getDefaultAdapter();

        $id = $db->fetchOne("SELECT email FROM user WHERE facebook_id = ".$this->_facebook->getUser());

        return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, $id);
    }
}